package com.game.battleship.db;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

public class UsersTable {

	public static final String USER_ID = "_ID";
	public static final String USER_USERNAME = "USERNAME";
	public static final String USER_PASSWORD = "PASSWORD";
	public static final String USER_SCORES = "SCORES";
	public static final String USER_NEXT_STAGE_ID = "NEXT_STAGE_ID";
	public static final String TABLE_NAME = "USERS";
	
	private static final String CREATE_TABLE =
			"create table " + TABLE_NAME + "(" +
			USER_ID + " integer primary key autoincrement," +
			USER_USERNAME + " text not null unique," +
			USER_PASSWORD + " text not null," +
			USER_SCORES + " integer not null default 0," +
			USER_NEXT_STAGE_ID + " integer not null," +
			"foreign key(" + USER_NEXT_STAGE_ID +") references " + StagesTable.TABLE_NAME + "(" + StagesTable.STAGE_ID + ")" +
					")";
	
	public static void onCreate(SQLiteDatabase db) throws SQLiteException {
		db.execSQL(CREATE_TABLE);
	}
}
